class Solution
{
public:
    bool canReach(vector<int> &arr, int start)
    {
        int n = arr.size();
        vector<bool> visited(n, false);
        queue<int> q;
        q.push(start);
        visited[start] = true;
        while (!q.empty())
        {
            int pos = q.front();
            q.pop();
            if (arr[pos] == 0)
            {
                return true;
            }
            if (pos - arr[pos] >= 0 && !visited[pos - arr[pos]])
            {
                q.push(pos - arr[pos]);
                visited[pos - arr[pos]] = true;
            }
            if (pos + arr[pos] < n && !visited[pos + arr[pos]])
            {
                q.push(pos + arr[pos]);
                visited[pos + arr[pos]] = true;
            }
        }
        return false;
    }
};